package com.fbs.wowo.chat.mapper;

import com.fbs.wowo.chat.entity.Friend;
import org.apache.ibatis.jdbc.SQL;

public class FriendSqlProvider {

    public String insertSelective(Friend record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("friend");
        
        if (record.getMid() != null) {
            sql.VALUES("mid", "#{mid,jdbcType=VARCHAR}");
        }
        
        if (record.getFid() != null) {
            sql.VALUES("fid", "#{fid,jdbcType=VARCHAR}");
        }
        
        if (record.getMyGroup() != null) {
            sql.VALUES("my_group", "#{myGroup,jdbcType=VARCHAR}");
        }
        
        if (record.getfGroup() != null) {
            sql.VALUES("f_group", "#{fGroup,jdbcType=VARCHAR}");
        }
        
        if (record.getMyNickname() != null) {
            sql.VALUES("my_nickname", "#{myNickname,jdbcType=VARCHAR}");
        }
        
        if (record.getfNickname() != null) {
            sql.VALUES("f_nickname", "#{fNickname,jdbcType=VARCHAR}");
        }
        
        if (record.getValid() != null) {
            sql.VALUES("valid", "#{valid,jdbcType=TINYINT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Friend record) {
        SQL sql = new SQL();
        sql.UPDATE("friend");
        
        if (record.getMyGroup() != null) {
            sql.SET("my_group = #{myGroup,jdbcType=VARCHAR}");
        }
        
        if (record.getfGroup() != null) {
            sql.SET("f_group = #{fGroup,jdbcType=VARCHAR}");
        }
        
        if (record.getMyNickname() != null) {
            sql.SET("my_nickname = #{myNickname,jdbcType=VARCHAR}");
        }
        
        if (record.getfNickname() != null) {
            sql.SET("f_nickname = #{fNickname,jdbcType=VARCHAR}");
        }
        
        if (record.getValid() != null) {
            sql.SET("valid = #{valid,jdbcType=TINYINT}");
        }
        
        sql.WHERE("mid = #{mid,jdbcType=VARCHAR}");
        sql.WHERE("fid = #{fid,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}